#include "DMA.h"                  // Device header

// TBD: match more peripherals
void MY_DMA_Init(uint8_t* src,uint32_t src_size)
{
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2,ENABLE);
	// Send msg to UART, Then back it to here
	DMA_InitTypeDef DMA_InitStruct;
	DMA_InitStruct.DMA_BufferSize = src_size;
	DMA_InitStruct.DMA_Channel = DMA_Channel_4;
	DMA_InitStruct.DMA_DIR = DMA_DIR_MemoryToPeripheral;
	DMA_InitStruct.DMA_FIFOMode = DMA_FIFOMode_Disable;
	DMA_InitStruct.DMA_Mode = DMA_Mode_Normal; // Not circular
	DMA_InitStruct.DMA_Priority = DMA_Priority_High;
	
	DMA_InitStruct.DMA_Memory0BaseAddr = (uint32_t)src; // array start addr
	DMA_InitStruct.DMA_PeripheralBaseAddr = (uint32_t)&(USART1->DR);
	DMA_InitStruct.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; // byte per
	DMA_InitStruct.DMA_PeripheralDataSize =  DMA_PeripheralDataSize_Byte;
	DMA_InitStruct.DMA_MemoryInc = DMA_MemoryInc_Enable;
	DMA_InitStruct.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
	
	DMA_InitStruct.DMA_MemoryBurst = DMA_MemoryBurst_Single;
	DMA_InitStruct.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
	//  One time for 4*small_pack --> In the burst mode
	
	//  USART_DMA TxSend Function
	//USART_DMACmd(USART1,USART_DMAReq_Tx,ENABLE);
	DMA_Init(DMA2_Stream7,&DMA_InitStruct);
}
